<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\widgets\Pjax;
use yii\grid\GridView;
use app\common\widgets\MyFileUpload;

/* @var $this yii\web\View */
/* @var $model app\models\GkyQyh */
/* @var $form yii\widgets\ActiveForm */
?>
<script src="../web/js/jquery.min.js" type="text/javascript"></script>
<script src="../web/js/common.js" type="text/javascript"></script>
<script type="text/javascript" src="js/qiniuupload/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/qiniuupload/plupload/plupload.full.min.js"></script>
<script type="text/javascript" src="js/qiniuupload/plupload/i18n/zh_CN.js"></script>
<script type="text/javascript" src="js/qiniuupload/ui.js"></script>
<script type="text/javascript" src="js/qiniuupload/qiniu.js"></script>
<script type="text/javascript" src="js/qiniuupload/highlight/highlight.js"></script>
<script type="text/javascript" src="js/qiniuupload/main.js"></script>
<div class="gky-qyh-form">
    <div class="panel panel-default">
        <!--<div class="panel-heading text-center" style="background: #003eff;color:white">gky-qyh</div>-->
        <div class="panel-body">
            <?php $form = ActiveForm::begin([
                'options' => ['class' => 'form-horizontal form-group','enctype' => 'multipart/form-data'],
                'fieldConfig' => [
                    'template' => "{label}<div class=\"col-lg-10\">{input}</div>",
                    'labelOptions' => ['class' => 'col-lg-2 control-label'],
                ]
            ]); ?>

            <div class="col-lg-6">
                <?= $form->field($model, 'qyhname')->textInput(['maxlength' => true]) ?>
            </div>
            <div class="col-lg-6">
                <?= $form->field($model, 'corpid')->textInput(['maxlength' => true]) ?>
            </div>
            <div class="col-lg-6">
                    上传二维码：
                <div class="col-lg-4" style="margin-left: 100px;">
                     <?= MyFileUpload::widget() ?>
                </div>
                 
            </div>
            <div class="col-lg-6">
                <?= $form->field($model, 'logo')->textInput(['maxlength' => true]) ?>
            </div>
            <div class="col-lg-6">
                <?= $form->field($model, 'addtime')->textInput(['maxlength' => true]) ?>
            </div>
            <div class="col-lg-6">
                <?= $form->field($model, 'accesstoken')->textInput(['maxlength' => true]) ?>
            </div>
            <div class="col-lg-6">
                <?= $form->field($model, 'expiretime')->textInput(['maxlength' => true]) ?>
            </div>
            <div class="col-lg-6">
                <?= $form->field($model, 'secret')->textInput(['maxlength' => true]) ?>
            </div>
            <div class="col-lg-12">
                <div class="col-lg-2">
                    <?= Html::a('Create', ['/gky-qyh-app/create'], ['class' => 'btn btn-primary']) ?>
                </div>
                <?php Pjax::begin(); ?>
                <?= GridView::widget([
                    'dataProvider' => $apps,
                    'columns' => [
//                        ['class' => 'yii\grid\SerialColumn'],

//                        'id',
                        'name',
                        'report_location_flag',
                        'logo_mediaid',
                        'description',
                        // 'redirect_domain',
                        // 'isreportuser',
                        // 'isreportenter',
                        // 'qid',
                        // 'addtime',

                        [
                            'class' => 'app\common\widgets\ActionColumn',
                            'template' => '{/gky-qyh-app/update:update}{/gky-qyh-menu/index:menu}{/gky-qyh-app/delete:delete}{/gky-qyh-app/set-app:set-app}',
                            'buttons' => [
                                //view button
                                'update' => function ($url) {
                                    return Html::a('<span class="fa fa-search"></span>编辑 ', $url, [
                                        'title' => Yii::t('app', '编辑'),
                                        'class' => 'btn btn-primary btn-xs',
                                    ]);
                                },
                                //update button
                                'menu' => function ($url,$model) {
//                                    return Html::a('<span class="fa fa-search"></span>菜单 ', $url, [
//                                        'title' => Yii::t('app', '菜单'),
//                                        'class' => 'btn btn-primary btn-xs',
//                                    ]);
                                    return Html::Button('菜单', ['onclick'=>'btncaidan()','name'=>$model->id,'class'=>'btn btn-primary btn-xs','title' => '菜单','id'=>'modalButton','data-toggle'=>'modal', 'data-target'=>'#modal']); 
                                },
                                //update button
                                'delete' => function ($url) {
                                    return Html::a('<span class="fa fa-search"></span>删除 ', $url, [
                                        'title' => Yii::t('app', '删除'),
                                        'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'),
                                        'data-method' => 'post',
                                        'data-pjax' => '0',
                                        'class' => 'btn btn-primary btn-xs',
                                    ]);
                                },
                                'set-app' => function ($url) {
                                    return Html::a('<span class="fa fa-search"></span>同步 ', $url, [
                                        'title' => Yii::t('app', '同步'),
                                        'class' => 'btn btn-primary btn-xs',
                                    ]);
                                },
                            ],
                        ],
                    ],
                ]); ?>
                <?php Pjax::end(); ?>
            </div>
            <div class="form-group">
                <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success col-lg-offset-5 col-xs-offset-5 col-sm-offset-5 col-md-offset-5' : 'btn btn-primary col-lg-offset-5 col-xs-offset-5 col-sm-offset-5 col-md-offset-5']) ?>
                <?= Html::a('Return', ['index'], ['class' => 'btn btn-primary']) ?>
            </div>

            <?php ActiveForm::end(); ?>
        </div>
    </div>

</div>

<?php yii\bootstrap\Modal::begin([
                'header'=>'菜单编辑器',
                'id'=>'modal',
                'size'=>'modal-lg',
                        ]);
                ?>   
         <?php 
              echo $this->render('popwindow',['model'=>new app\models\GkyQyhApp()]); 
          ?>
 <?php yii\bootstrap\Modal::end() ?>

<script type="text/javascript">
    //控制导航菜单的开关
    function btncaidan(){
        if($("#caidan", window.parent.document))
        {
            $("#caidan", window.parent.document).removeClass("funcmenu_switcher");
            $("#caidan", window.parent.document).addClass("funcmenu_switcher active");
            $("#body", window.parent.document).removeClass("TOS");
            $("#body", window.parent.document).addClass("TOS open-menu");
        }
    }
     $(".close").click(function(){
        $("#caidan", window.parent.document).removeClass("funcmenu_switcher active");
        $("#caidan", window.parent.document).addClass("funcmenu_switcher");
        $("#body", window.parent.document).removeClass("TOS open-menu");
        $("#body", window.parent.document).addClass("TOS");
    });
</script>